<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <SearchForm
      v-model:search-items="searchItems"
      :form-config="formConfig"
      :cache-key="_props.cacheKey"
      @search="handleSearch"
    />
  </ele-card>
</template>

<script setup>
import { ref } from "vue";
import SearchForm from "@/components/CommonSearch/SearchForm.vue";

const emit = defineEmits(["search"]);
// 定义接收的props
const _props = defineProps({
  cacheKey: {
    type: String,
    required: true,
  },
});
// 定义搜索项配置
const searchItems = ref([
  {
    label: "机构名称",
    prop: "organization_name",
    component: "el-input",
    visible: true,
    span: { lg: 6, md: 8, sm: 12, xs: 24 },
    props: {
      clearable: true,
      placeholder: "请输入机构名称",
    },
  },
  {
    label: "机构类型",
    prop: "organization_type",
    component: "DictData",
    visible: true,
    span: { lg: 6, md: 8, sm: 12, xs: 24 },
    props: {
      code: "organization_type",
      placeholder: "请选择机构类型",
    },
  },
]);

/** 表单配置 */
const formConfig = ref({
  organization_name: "",
  organization_type: void 0,
});

/** 处理搜索 */
const handleSearch = (formData) => {
  emit("search", { ...formData });
};
</script>
